﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace postSale
{
    public partial class testForm : application.baseForm 
    {
        public testForm()
        {
            InitializeComponent();
            postSale.SysLibs.InitSendMailInfo();
            CommonTypes.Settings.sysLoginInfo.UserId = (int)userIdEd.Value;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            postSale.forms.taskList myForm = new postSale.forms.taskList();
            myForm.Show();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            postSale.forms.message myForm = new postSale.forms.message();
            if (myForm.LoadInCompletedTasks() == 0)
            {
                myForm.Dispose();
                return;
            }
            myForm.Show();
        }

        private void activateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Activate();
        }

        private void closeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void notifyIcon1_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (this.WindowState == FormWindowState.Minimized)
                this.WindowState = FormWindowState.Normal;
            this.Activate();
        }

        private void button4_Click(object sender, EventArgs e)
        {
            try
            {
                postSale.SysLibs.Create_PlanTasks();
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }

        private void button5_Click(object sender, EventArgs e)
        {
            try
            {
                postSale.SysLibs.Notification_IncompletedTask();
            }
            catch (Exception er)
            {
                this.ShowError(er);
            }
        }

        private void button3_Click(object sender, EventArgs e)
        {
            string tmp = common.EnvironmentLibs.GetExecutePath();
            tmp = common.fileFuncs.FileNamePath(tmp);
            tmp = common.fileFuncs.MakeFileName(tmp,"sysconfig.xml");
            common.SysLibs.ShowMessage(tmp);

            common.Settings.sysConfigFile = common.fileFuncs.GetFullPath(common.Settings.sysConfigFile);

            //Encryption key should be set before the below commands
            application.ConfigLibs.withEncryption = true;
            common.configuration.withEncryption = true;
            application.ConfigLibs.Load_User_Config(false);
        }

        private void button6_Click(object sender, EventArgs e)
        {
            postSale.forms.processList myForm = new postSale.forms.processList();
            myForm.Show();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            postSale.forms.processWorkList myForm = new postSale.forms.processWorkList();
            myForm.Show();
        }

        private void userIdEd_Validated(object sender, EventArgs e)
        {
            CommonTypes.Settings.sysLoginInfo.UserId = (int)userIdEd.Value;
        }

        private void button11_Click(object sender, EventArgs e)
        {
            postSale.forms.processAssignList myForm = new postSale.forms.processAssignList();
            myForm.Show();
        }
    }
}
